﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MoPhongLapLich
{
    public class Process
    {
        private int _timeWait;
        private List<Cycle> _cycles;

        public int Id { get; set; }
        public bool IsProcessing { get; set; }
        public int TimeWait
        {
            get { return _timeWait; }
        }

        public List<Cycle> Cycles
        {
            get { return _cycles; }
            set { _cycles = value; }
        }

        public void AddTimewait()
        {
            _timeWait++; 
        }

        public bool HasCycle()
        {
            return Cycles.Count > 1;
        }
        public void NextCycle()
        {
            if(Cycles.Count!=0) Cycles.RemoveAt(0);
        }
        public int GetCpu()
        {
            if (Cycles.Count != 0) return Cycles[0].Cpu;
            return -1;
        }
        public void DecCpu()
        {
            if (Cycles.Count != 0 ) Cycles[0].Cpu--;

        }
        public int GetR1()
        {
            if (Cycles.Count!=0) return Cycles[0].R1;
            return -1;
        }
        public void DecR1()
        {
            if (Cycles.Count != 0) Cycles[0].R1--;
        }
        public int GetR2()
        {
            if (Cycles.Count != 0) return Cycles[0].R2;
            return -1;
        }
        public void DecR2()
        {
            if (Cycles.Count != 0) Cycles[0].R2--;
        }
    }

    public class Cycle
    {
        public int Cpu;
        public int R1;
        public int R2;
    }

}
